PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

If (Compound Statement)

A compound If statement contains one or more Boolean expressions and groups of statements to be executed if the value of the corresponding Boolean expression is true .

SYNTAX
if Boolean [ then ]
    [ statement ]...
[ else if Boolean [ then ]
    [ statement ]...]...
[ else
    [ statement ]...]
end [ if ]

where

Boolean is an expression whose value is true or false .

statement is any AppleScript statement.

EXAMPLE

The following example creates a string that specifies whether one value is greater than, less than, or the same as a second value.

if ( x > y ) then
    set myMessage to " is greater than "
else if ( x < y ) then
    set myMessage to " is less than "
else
    set myMessage to " is equal to "
end if
set myResult to (x as string) & myMessage & (y as string)

© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)